package com.example.service;

import com.example.entity.Articles;
import com.example.entity.Checkpoint;
import com.example.mapper.CheckpointMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
关卡业务处理
 */
@Service
public class CheckpointService {

    @Resource
    private CheckpointMapper checkpointMapper;

    public void add(Checkpoint checkpoint) {
        checkpointMapper.insert(checkpoint);
    }

    public void deleteById(Integer id) {
        checkpointMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(Checkpoint checkpoint) {
        checkpointMapper.updateById(checkpoint);
    }

    public Checkpoint selectById(Integer id) {
        return checkpointMapper.selectById(id);
    }

    public List<Checkpoint> selectAll(Checkpoint checkpoint) {
        return checkpointMapper.selectAll(checkpoint);
    }

    public PageInfo<Checkpoint> selectPage(Checkpoint checkpoint, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Checkpoint> checkpointList = checkpointMapper.selectAll(checkpoint);
        return PageInfo.of(checkpointList);
    }
}
